package com.yzt.dynamicmodule.adapter;

import android.graphics.Color;

import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.yzt.zhuju.network.entity.game.GameListBean;
import com.yzt.dynamicmodule.R;
import com.yzt.plugin_imageloader.ImageLoadUtil;
import com.yzt.zhuju.widget.tuiview.TUITextView;

/**
 * author : bob
 * date   : 2023/2/27
 * desc   : 动态的适配器
 */
public class ActivityListAdapter extends BaseQuickAdapter<GameListBean, BaseViewHolder> implements LoadMoreModule {

    public ActivityListAdapter() {
        super(R.layout.item_activity_list);
    }

    @Override
    protected void convert(BaseViewHolder holder, GameListBean item) {

        ImageLoadUtil.loadAvatar(getContext(), item.getCover(), holder.getView(R.id.img_cover));
        holder.setText(R.id.tv_name, item.getActivitySubject());
        holder.setText(R.id.tv_time, item.getStartTime() + " - " + item.getEndTime());
        holder.setText(R.id.tv_address, item.getLocation());
        holder.setText(R.id.tv_start_time, "距离开始时间：" + item.getStartTime());

        TUITextView tvStatus = holder.findView(R.id.tv_status);


        holder.setVisible(R.id.tv_start_time, false);

        // 活动状态 [ 0：未付款(创建活动为我付款时候)，10：未开始，20：进行中，30：活动结束，40：活动取消 ]
        if (item.getActivityStatus() == 0) {
            holder.setText(R.id.tv_status, "未付款");
            tvStatus.setBackground(ContextCompat.getDrawable(tvStatus.getContext(), R.drawable.shape_not_pay));
            tvStatus.setTextColor(Color.WHITE);
        } else if (item.getActivityStatus() == 10) {
            holder.setText(R.id.tv_status, "未开始");
            tvStatus.setBackground(ContextCompat.getDrawable(tvStatus.getContext(), R.drawable.shape_not_pay));
            tvStatus.setTextColor(Color.WHITE);
            holder.setVisible(R.id.tv_start_time, true);
        } else if (item.getActivityStatus() == 20) {
            holder.setText(R.id.tv_status, "进行中");
            tvStatus.setBackground(ContextCompat.getDrawable(tvStatus.getContext(), R.drawable.shape_game_ongoing));
            tvStatus.setTextColor(Color.BLACK);
        } else if (item.getActivityStatus() == 30) {
            holder.setText(R.id.tv_status, "已结束");
            tvStatus.setBackground(ContextCompat.getDrawable(tvStatus.getContext(), R.drawable.shape_not_pay));
            tvStatus.setTextColor(Color.BLACK);
        } else if (item.getActivityStatus() == 40) {
            holder.setText(R.id.tv_status, "已取消");
            tvStatus.setBackground(ContextCompat.getDrawable(tvStatus.getContext(), R.drawable.shape_not_pay));
            tvStatus.setTextColor(Color.WHITE);
        }
    }
}